class Solution {
public:
    int MoreThanHalfNum_Solution(vector<int> numbers) {
        if(numbers.empty()) return 0;
        int res = numbers[0];
        int times = 1;
        for(int i = 1; i < numbers.size();++i){
            if(0 == times){
                times = 1;
                res = numbers[i];
            }
            else if(res == numbers[i])
                ++times;
            else
                --times;
        }
        // 检验是否有符合结果
        times = 0;
        for(int i = 0; i < numbers.size(); ++i){
            if(res == numbers[i]) ++times;
        }
        return (times > numbers.size()/2) ? res : 0;
    }
};